package cn.com.visionsky.bocsz.bda.webservice.handler.customer_tags_query;

import cn.com.visionsky.bocsz.bda.webservice.Constants;
import cn.com.visionsky.bocsz.bda.webservice.cache.FieldPermissionsCache;
import cn.com.visionsky.bocsz.bda.webservice.handler.Handler;
import cn.com.visionsky.bocsz.bda.webservice.permission.RequestedCustomerTags;
import cn.com.visionsky.bocsz.bda.webservice.ws.FullTextUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.hadoop.hbase.HbaseTemplate;
import org.springframework.stereotype.Component;
import org.apache.hadoop.hbase.client.Result;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhouqiufu on 2018/1/30.
 */
@Component
public class CustomerTagsQueryHandler implements Handler {

    private static final Logger logger = LoggerFactory.getLogger(CustomerTagsQueryHandler.class);

    public static final String TABLE_CST_LBL_INFO = "CST_LBL_INFO";
    public static final String TABLE_CST_BSC_INF = "CST_BSC_INF";

    public static final String separator = ",";

    @Autowired
    private HbaseTemplate hbaseTemplate;

    public String handle(final String fullTextRequestStr, HttpServletRequest request)  {
        logger.info(String.format("fullTextRequestStr: %s", fullTextRequestStr));

        List<String> ctfNoList = new ArrayList<String>();//客户证件号

        FullTextRequest fullTextRequest = FullTextUtils.getFullTextRequest(FullTextRequest.class, fullTextRequestStr);

        String mode = fullTextRequest.getMode();//查询模式
        switch(mode){
           case Constants.CST_ID_MODE://客户号模式
               List<String> rowKeyList = new ArrayList<String>();

               String cstId = fullTextRequest.getCstId().trim();
               if(cstId.contains(separator)){
                   String[] cstIdArray = cstId.split(separator);
                   for(String element : cstIdArray){
                       if(StringUtils.isNotBlank(element)){
                           rowKeyList.add(element.trim());
                       }

                   }
               }else{
                   rowKeyList.add(cstId);
               }

               List<String> list = preprocess(TABLE_CST_BSC_INF, rowKeyList);
               if(!list.isEmpty()){
                   ctfNoList.addAll(list);
               }

               break;

           case Constants.CTF_NO_MODE://客户证件号模式
               String ctfNo = fullTextRequest.getCtfNo().trim();
               if(ctfNo.contains(separator)){//分割符：英文逗号
                   String[] ctfNoArray = ctfNo.split(separator);
                   for (String element : ctfNoArray) {
                       if(StringUtils.isNotBlank(element)){
                           ctfNoList.add(element.trim());
                       }

                   }
               }else{
                   ctfNoList.add(ctfNo);
               }
               break;

            default:
                break;
        }

        //查询结果
        List<CstLblInfo> allResultList = null;
        if(!ctfNoList.isEmpty()){
            String clientIp = request.getRemoteAddr();
            String key = clientIp + Constants.CUSTOMER_TAGS_QUERY_HANDLER_MODULE.toUpperCase();
            //查询授权字段
            Map<String, List<String>> fieldPermissionsCacheMap = FieldPermissionsCache.getFieldPermissionsCacheMap();//全大写key is ip+interfaceName

            List<String> authorizationFieldList = fieldPermissionsCacheMap.get(key);
            if(authorizationFieldList != null && !authorizationFieldList.isEmpty()){
                //识别客户端请求的字段
                RequestedCustomerTags RequestedCustomerTags = new RequestedCustomerTags(fullTextRequest);
                List<String> requestedFieldList = RequestedCustomerTags.discernRequestedField();//不包括：客户号、客户证件号
                allResultList = scanTable(TABLE_CST_LBL_INFO, ctfNoList, authorizationFieldList, fullTextRequest, requestedFieldList);
                logger.info("Customer Tags Query Module Result List Size:"+allResultList.size());
            }
        }

        final FullTextResponse fullTextResponse = new FullTextResponse();
        fullTextResponse.setCstLblInfoList(allResultList);
        return FullTextUtils.getFullTextResponseStr(fullTextResponse);
    }


    /*
        预处理：根据客户号查询客户证件号
     */
    private List<String> preprocess(String tableName, List<String> rowKeyList){

        List<String> ctfNoList = new ArrayList<String>();

        Result[] results = getResultArray(tableName, rowKeyList);//直接查getList<Get>

        if(results != null){
            for (Result result : results){//对返回的结果集进行操作//行操作
                Map<String, String> resultMap = new HashMap<String, String>();
                for (Cell cell : result.rawCells()) {//列操作
                    if(cell != null){
                        String key = Bytes.toString(CellUtil.cloneQualifier(cell));
                        String value = Bytes.toString(CellUtil.cloneValue(cell));
                        resultMap.put(key, value);
                    }
                }
                ctfNoList.add(resultMap.get(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CTF_NO));
            }
        }

        return ctfNoList;
    }

    private Result[] getResultArray(String tableName, List<String> rowKeyList){
        Configuration conf = hbaseTemplate.getConfiguration();
        Connection connection = null;
        try{
            List<Get> getList = new ArrayList();
            connection = ConnectionFactory.createConnection(conf);
            Table table = connection.getTable( TableName.valueOf(tableName));// 获取表
            for (String rowkey : rowKeyList){//把rowkey加到get里，再把get装到list中
                if(StringUtils.isNotBlank(rowkey)){
                    Get get = new Get(Bytes.toBytes(rowkey));
                    getList.add(get);
                }
            }
            return table.get(getList);//直接查getList<Get>

        }catch(IOException iOException){
            iOException.printStackTrace();
            logger.info("[getResultArray] get result error");
            return null;
        }finally {
            try{
                if(connection != null){
                    connection.close();
                }
            }catch(IOException e){logger.info("[getResultArray] shutdown Connection error");}
        }
    }
    /*
    扫描表
     */
    private List<CstLblInfo> scanTable(String tableName, List<String> rowKeyList, List<String> authorizationFieldList, FullTextRequest fullTextRequest, List<String> requestedFieldList){

        List<CstLblInfo> resultList = new ArrayList<CstLblInfo>();

        Result[] results = getResultArray(tableName, rowKeyList);//直接查getList<Get>
        if(results != null){
            for (Result result : results){//对返回的结果集进行操作//行操作
                Map<String, String> resultMap = new HashMap<String, String>();
                for (Cell cell : result.rawCells()) {//列操作
                    if(cell != null){
                        String key = Bytes.toString(CellUtil.cloneQualifier(cell));
                        String value = Bytes.toString(CellUtil.cloneValue(cell));
                        resultMap.put(key, value);
                    }
                }
                boolean continueTag = true;//请求字段满足要求标识
                continueTag = checkField(fullTextRequest, requestedFieldList, continueTag, resultMap);
                if(continueTag){
                    CstLblInfo cstLblInfo = setValue(resultMap, authorizationFieldList, fullTextRequest.getQueryField());
                    if(StringUtils.isNotBlank(cstLblInfo.getCtfNo())){
                        resultList.add(cstLblInfo);
                    }

                }else{
                    continue;
                }
            }
        }

        return resultList;
    }

    //返回结果
    private CstLblInfo setValue(Map<String, String> resultMap, List<String> authorizationFieldList, String queryField){
        CstLblInfo cstLblInfo = new CstLblInfo();

        if(authorizationFieldList != null && !authorizationFieldList.isEmpty()){

            final int ONE_RESULT = 1;
            final String ALL_FIELD = "*";
            if(authorizationFieldList.size() == ONE_RESULT){
                if(authorizationFieldList.contains(ALL_FIELD)){
                    List<String> allFieldList = new ArrayList<String>();

                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_ETL_DATE);//数据日期
                    //allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CTF_NO);//证件号
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CST_NM);//客户姓名
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_SEX);//性别
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_BIRTHDAY);//生日
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_AGE);//年龄段
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_AC_NO_GJJ);//公积金帐号
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_PRE_SALARY);//预测月薪
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_BOC_STAFF);//中行员工标识
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_LVL_KYC);//KYC风险等级
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_MOBPHN_NO);//手机号码
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_TEL_CHECK);//验证标记
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_OCCU_CODE);//职业代码
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_GAT);//港澳台客户标志
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_NATIONALITY);//国籍
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_NATION);//民族
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_HOME_ADR);//家庭地址
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_UNIT_ADR);//客户单位地址
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_EMAIL);//电子邮件
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_MARITAL_STATUS);//婚姻状况
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_EDUCATION_CODE);//教育程度
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_UNIT_NM);//客户单位名称
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_MGR);//高管标识
                    allFieldList.add(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_GROUP_CODE);//客户群标识

                    authorizationFieldList = allFieldList;
                }
            }

            if(StringUtils.isNotBlank(queryField)){//表示需要进一步缩小查询字段的范围
                List<String> queryFieldList = new ArrayList<String>();
                if(queryField.contains(separator)){//包含分隔符
                    String[] queryFieldArray = queryField.split(separator);
                    for(String element : queryFieldArray){
                        if(StringUtils.isNotBlank(element)){
                            queryFieldList.add(element.trim().toUpperCase());
                        }
                    }
                }else{//某个字段的名称
                    queryFieldList.add(queryField.trim().toUpperCase());
                }
                authorizationFieldList = queryFieldList;
            }

            //返回允许查看的字段
            for(String authorizationFiel : authorizationFieldList){
                switch(authorizationFiel){
                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_ETL_DATE       :
                        //数据日期
                        cstLblInfo.setEtlDate(resultMap.get(authorizationFiel));
                        break;
                    /*
                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CTF_NO         :

                        cstLblInfo.setCtfNo(resultMap.get(authorizationFiel));
                        break;
                     */
                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CST_NM         :
                        //客户姓名
                        cstLblInfo.setCstNm(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_SEX            :
                        //性别
                        cstLblInfo.setSex(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_BIRTHDAY       :
                        //生日
                        cstLblInfo.setBirthday(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_AGE            :
                        //年龄段
                        cstLblInfo.setAge(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_AC_NO_GJJ      :
                        //公积金帐号
                        cstLblInfo.setAcNoGjj(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_PRE_SALARY     :
                        //预测月薪
                        cstLblInfo.setPreSalary(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_BOC_STAFF   :
                        //中行员工标识
                        cstLblInfo.setIsBocStaff(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_LVL_KYC        :
                        //KYC风险等级
                        cstLblInfo.setLvlKyc(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_MOBPHN_NO      :
                        //手机号码
                        cstLblInfo.setMobphnNo(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_TEL_CHECK      :
                        //验证标记
                        cstLblInfo.setTelCheck(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_OCCU_CODE      :
                        //职业代码
                        cstLblInfo.setOccuCode(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_GAT         :
                        //港澳台客户标志
                        cstLblInfo.setIsGat(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_NATIONALITY    :
                        //国籍
                        cstLblInfo.setNationality(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_NATION         :
                        //民族
                        cstLblInfo.setNation(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_HOME_ADR       :
                        //家庭地址
                        cstLblInfo.setHomeAdr(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_UNIT_ADR       :
                        //客户单位地址
                        cstLblInfo.setUnitAdr(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_EMAIL          :
                        //电子邮件
                        cstLblInfo.setEmail(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_MARITAL_STATUS :
                        //婚姻状况
                        cstLblInfo.setMaritalStatus(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_EDUCATION_CODE :
                        //教育程度
                        cstLblInfo.setEducationCode(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_UNIT_NM        :
                        //客户单位名称
                        cstLblInfo.setUnitNm(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_MGR         :
                        //高管标识
                        cstLblInfo.setIsMgr(resultMap.get(authorizationFiel));
                        break;

                    case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_GROUP_CODE     :
                        //客户群标识
                        cstLblInfo.setGroupCode(resultMap.get(authorizationFiel));
                        break;

                    default:
                        break;
                }
            }
        }

        String ctfNo = resultMap.get(Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CTF_NO);
        if(StringUtils.isNotBlank(ctfNo)){
            cstLblInfo.setCtfNo(ctfNo);
        }

        return cstLblInfo;
    }

    //判断数据是否符合查询条件
    private boolean checkField(FullTextRequest fullTextRequest, List<String> requestedFieldList, boolean continueTag, Map<String, String> resultMap){

        String etlDate = fullTextRequest.getEtlDate();
        String cstNm = fullTextRequest.getCstNm();
        String sex = fullTextRequest.getSex();
        String birthday = fullTextRequest.getBirthday();
        String age = fullTextRequest.getAge();
        String acNoGjj = fullTextRequest.getAcNoGjj();
        String preSalary = fullTextRequest.getPreSalary();
        String isBocStaff = fullTextRequest.getIsBocStaff();
        String lvlKyc = fullTextRequest.getLvlKyc() ;
        String mobphnNo = fullTextRequest.getMobphnNo();
        String telCheck = fullTextRequest.getTelCheck();
        String occuCode = fullTextRequest.getOccuCode();
        String isGat = fullTextRequest.getIsGat();
        String nationality = fullTextRequest.getNationality();
        String nation = fullTextRequest.getNation();
        String homeAdr = fullTextRequest.getHomeAdr();
        String unitAdr = fullTextRequest.getUnitAdr();
        String email = fullTextRequest.getEmail();
        String maritalStatus = fullTextRequest.getMaritalStatus();
        String educationCode = fullTextRequest.getEducationCode();
        String unitNm = fullTextRequest.getUnitNm();
        String isMgr = fullTextRequest.getIsMgr();
        String groupCode = fullTextRequest.getGroupCode();

        if(requestedFieldList != null && !requestedFieldList.isEmpty()){
            for(String requestedField : requestedFieldList) {
                if(continueTag){
                    String fieldValue = resultMap.get(requestedField);
                    switch(requestedField){ //只要有一个字段的内容不符合查询要求，该行的数据就不能返回//CST_ID 和 CTF_NO不进行操作
                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_ETL_DATE       :
                            //数据日期
                            if(StringUtils.isNotBlank(etlDate) && !StringUtils.equals(etlDate.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_CST_NM         :
                            //客户姓名
                            if(StringUtils.isNotBlank(cstNm) && !StringUtils.equals(cstNm.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_SEX            :
                            //性别
                            if(StringUtils.isNotBlank(sex) && !StringUtils.equals(sex.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_BIRTHDAY       :
                            //生日
                            if(StringUtils.isNotBlank(birthday) && !StringUtils.equals(birthday.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_AGE            :
                            //年龄段
                            if(StringUtils.isNotBlank(age) && !StringUtils.equals(age.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_AC_NO_GJJ      :
                            //公积金帐号
                            if(StringUtils.isNotBlank(acNoGjj) && !StringUtils.equals(acNoGjj.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_PRE_SALARY     :
                            //预测月薪
                            if(StringUtils.isNotBlank(preSalary) && !StringUtils.equals(preSalary.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_BOC_STAFF   :
                            //中行员工标识
                            if(StringUtils.isNotBlank(isBocStaff) && !StringUtils.equals(isBocStaff.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_LVL_KYC        :
                            //KYC风险等级
                            if(StringUtils.isNotBlank(lvlKyc) && !StringUtils.equals(lvlKyc.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_MOBPHN_NO      :
                            //手机号码
                            if(StringUtils.isNotBlank(mobphnNo) && !StringUtils.equals(mobphnNo.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_TEL_CHECK      :
                            //验证标记
                            if(StringUtils.isNotBlank(telCheck) && !StringUtils.equals(telCheck.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_OCCU_CODE      :
                            //职业代码
                            if(StringUtils.isNotBlank(occuCode) && !StringUtils.equals(occuCode.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_GAT         :
                            //港澳台客户标志
                            if(StringUtils.isNotBlank(isGat) && !StringUtils.equals(isGat.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_NATIONALITY    :
                            //国籍
                            if(StringUtils.isNotBlank(nationality) && !StringUtils.equals(nationality.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_NATION         :
                            //民族
                            if(StringUtils.isNotBlank(nation) && !StringUtils.equals(nation.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_HOME_ADR       :
                            //家庭地址
                            if(StringUtils.isNotBlank(homeAdr) && !StringUtils.equals(homeAdr.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_UNIT_ADR       :
                            //客户单位地址
                            if(StringUtils.isNotBlank(unitAdr) && !StringUtils.equals(unitAdr.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_EMAIL          :
                            //电子邮件
                            if(StringUtils.isNotBlank(email) && !StringUtils.equals(email.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_MARITAL_STATUS :
                            //婚姻状况
                            if(StringUtils.isNotBlank(maritalStatus) && !StringUtils.equals(maritalStatus.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_EDUCATION_CODE :
                            //教育程度
                            if(StringUtils.isNotBlank(educationCode) && !StringUtils.equals(educationCode.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_UNIT_NM        :
                            //客户单位名称
                            if(StringUtils.isNotBlank(unitNm) && !StringUtils.equals(unitNm.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_IS_MGR         :
                            //高管标识
                            if(StringUtils.isNotBlank(isMgr) && !StringUtils.equals(isMgr.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        case Constants.CUSTOMER_TAGS_QUERY_MOUDLE_GROUP_CODE     :
                            //客户群标识
                            if(StringUtils.isNotBlank(groupCode) && !StringUtils.equals(groupCode.trim(), fieldValue)){
                                continueTag = false;
                            }
                            break;

                        default:
                            break;
                    }
                }else{
                    break;
                }
            }
        }
        return continueTag;
    }


}


